﻿using M.Warehouse.API.Application.Command.FinishedProductCommand;
using M.Warehouse.Domain;
using M.Warehouse.Repository.WarehouseInterface;
using MediatR;

namespace M.Warehouse.API.Application.CommandHandlers.FinishedProductHandlers
{
    public class FinishedProductBqackfillCommandHandlers : IRequestHandler<FinishedProductBqackfillCommand, FinishedProduct>
    {
        private readonly IFinishedProductRepository _finishedProductRepository;
        public FinishedProductBqackfillCommandHandlers(IFinishedProductRepository finishedProductRepository)
        {
            _finishedProductRepository = finishedProductRepository;
        }
        /// <summary>
        /// 返填成品
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        public async Task<FinishedProduct> Handle(FinishedProductBqackfillCommand request, CancellationToken cancellationToken)
        {
            return (await _finishedProductRepository.GetAllAsync()).Where(x=>x.FinishedProductId==request.FinishedProductId).FirstOrDefault();
        }
    }
}
